import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
import './assets/global.css'
import axios from 'axios'
import './assets/fonts/iconfont.css'
import ZkTable from 'vue-table-with-tree-grid'
import VueQuillEditor from 'vue-quill-editor'
// require styles
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
Vue.use(VueQuillEditor)
axios.defaults.baseURL = 'http://liufusong.top:8888/api/private/v1/'
Vue.component('tree-grid', ZkTable)
axios.interceptors.request.use(config => {
  // console.log(config)
  if (config.url !== 'login') {
    // 我们要把我们携带的token给后台
    config.headers.Authorization = sessionStorage.getItem('token')
  }
  return config
  // 要把config退出去让内部接收
})
Vue.filter('formatDate', (date) => {
  const dateObj = new Date(date * 1000)
  const y = dateObj.getFullYear()
  const M = (dateObj.getMonth() + 1).toString().padStart(2, 0)
  const d = dateObj.getDate().toString().padStart(2, 0)
  return `${y}-${M}-${d}`
})
Vue.prototype.$axios = axios
// console.log(axios)
Vue.config.productionTip = false

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
